home *** CD-ROM | disk | FTP | other *** search
- %%
- %% YAMPSMail V1.2 © 1999 by Alastair M. Robinson
- %% Just a bit of PostScript code to print E-Mails from YAM
- %% in a slightly more presentable format.
- %%
- %% The routines presented here are a subset of some automatic text
- %% formatting routines I wrote a while back. Feel free to modify them
- %% to suit your own needs/tastes, but don't try to pass them off as
- %% your own work.
- %%
- %% If you've made some cool changes I'd appreciate seeing the result!
- %% Mail me at:blackfive@fakenhamweb.co.uk
- %%
-
- %% BeginProlog
-
- %% If you want to translate PSMail into another language,
- %% you can change (Page ) below to (Seite ) or whatever is
- %% the equivalent in your language.
-
- /PageString (Page ) def
- /RasterizingPageString (Rasterizing Page ) def
- /PrintingPageString (Printing Page ) def
-
- %% The following array contains a list of headers to be printed.
- %% Each entry must be of the form:
- %% [ /Name (Search key ) (Printed Name)]
- %% Name must be unique - if things start behaving strangely, try choosing
- %% different names for your custom headers.
- %%
- %% Printed Name can be changed, allowing you to translate the printout
- %% into other languages.
- %%
- %% The search key is case-sensitive; you might find that you need to
- %% define separate entries for different capitalizations, i.e.
- %% [ /ContentType1 (Content-type: ) (Content-type: )]
- %% [ /ContentType2 (Content-Type: ) (Content-Type: )]
- %%
- %% Sample entries for the most common headers are listed below, but commented
- %% out. To activate them, just remove the %% signs.
-
- /CustomHeaders
- [
- [ /MailTo (To: ) (To: )]
- [ /MailFrom (From: ) (From: )]
- [ /Organisation (Organisation: ) (Organisation: )]
- %% [ /XMailer (X-Mailer: ) (Mailer: )]
- %% [ /MessageID (Message-ID: ) (Message ID: )]
- %% [ /InReplyTo (In-Reply-To: ) (In Reply To: )]
- %% [ /MIMEVersion (MIME-Version: ) (MIME Version: )]
- %% [ /ContentType1 (Content-type: ) (Content Type: )]
- %% [ /ContentType2 (Content-Type: ) (Content Type: )]
- ] def
-
- %%
- %% The following sizes and font names can be changed to suit your tastes.
- %%
-
- /BodySize 10 def
- /BodyFont {/Palatino} def
-
- /HeadingSize 10 def
- /HeadingFont {/Palatino-Bold} def
-
- /TitleSize 15 def
- /TitleFont {/Palatino-BoldItalic} def
-
- %%
- %% Don't change anything below here unless you know what you're doing.
- %%
-
- clippath pathbbox
- /PageHeight exch def
- /PageWidth exch def
- /PageBottom exch def
- /PageLeft exch def
- /PageHeight PageHeight PageBottom sub def
- /PageWidth PageWidth PageLeft sub def
- newpath
- PageLeft PageBottom translate
-
- /HeaderMargin 34 def
- /TopMargin PageHeight 20 sub HeaderMargin neg add def
- /LeftMargin 45 def
- /RightMargin PageWidth 45 sub def
- /FooterMargin 20 def
- /BottomMargin 25 FooterMargin add def
-
- /Columns 1 def
- /Gutter 0 def
-
- /PageNo 1 def
- /PageNoString 8 string def
- /Title () def
-
- /ListingSize 8 def
- /ListingFont {/Courier} def
-
- /Leading 2 def
-
- /FindFontISO %% name
- {
- findfont
- dup /Encoding get 65 get /A eq % Check for symbol or dingbat encoding
- {
- dup length dict begin {1 index /FID ne {def} {pop pop} ifelse} forall
- /Encoding ISOLatin1Encoding def currentdict end
- dup /FontName get dup length string cvs dup length dup
- 7 add string 2 index 1 index copy pop
- exch 1 index exch (-Latin1) putinterval exch pop
- cvn exch definefont
- } if
- } def
-
- /RightAlign %% String XPos YPos
- { 2 index stringwidth pop neg 2 index add exch moveto pop show } def
-
- /LeftAlign %% String XPos YPos
- { moveto show } def
-
- /Centre %% String XPos YPos
- { exch 2 index stringwidth pop 2 div sub exch moveto show } def
-
-
- /SetStatus
- {
- (t:YAMPrintStatus) (w) file
- exch 1 index exch writestring
- dup PageNo 15 string cvs writestring
- closefile
- } def
-
-
- /BeginPage
- {
- RasterizingPageString SetStatus
- /ColumnWidth RightMargin LeftMargin neg add
- Gutter Columns -1 add mul neg add
- Columns div def
- /BlockLeftEdge LeftMargin def
- /BlockRightEdge BlockLeftEdge ColumnWidth add def
- /XPos LeftMargin def
- /YPos TopMargin def
- DoHeader DoFooter
- } def
-
-
- /EndPage
- {
- PrintingPageString SetStatus
- showpage
- PageLeft PageBottom translate
- /PageNo PageNo 1 add def
- } def
-
-
- /DoHeader
- {
- 2 setlinewidth 0 0 0 setrgbcolor
- LeftMargin -10 add TopMargin 5 add RightMargin 10 add 1 index
- moveto lineto stroke
- TitleFont FindFontISO TitleSize scalefont setfont
- Title LeftMargin TopMargin 12 add LeftAlign
- } def
-
-
- /DoFooter
- {
- 2 setlinewidth 0 0 0 setrgbcolor
- LeftMargin -10 add BottomMargin TitleSize neg add RightMargin 10 add 1 index
- moveto lineto stroke
- TitleFont FindFontISO TitleSize 3 mul 4 div scalefont setfont
- /Foot where
- {
- pop Foot LeftMargin RightMargin add 2 div BottomMargin 28 neg add Centre
- } if
- PageString PageNo PageNoString cvs
- stringwidth pop neg RightMargin add BottomMargin 28 neg add RightAlign
- PageNo PageNoString cvs RightMargin BottomMargin 28 neg add RightAlign
- /Date where
- {
- pop Date LeftMargin BottomMargin 28 neg add LeftAlign
- } if
- } def
-
-
- /ClearMailHeader %% HeaderName ClearMailHeader
- {
- dup where {exch undef} {pop} ifelse
- } def
-
-
- /PrintMailHeaders %% PrintMailHeaders
- {
- CustomHeaders
- {
- dup 2 get exch
- 0 get dup where
- {
- exch get concatstrings HeadingLeft
- }
- { pop pop } ifelse
- } forall
- } def
-
-
- /DefMailHeader %% HeaderLine HeaderName HeaderText DefMailHeader
- {
- exch /HeaderName exch def
- search
- {
- length 0 eq
- {
- pop HeaderName exch def pop () ()
- }
- {
- pop pop dup
- } ifelse
- } if
- } def
-
-
- /ParseMailHeader %% filename
- {
- /Title () def
- /Date () def
- CustomHeaders { 0 get dup where {exch undef} {pop} ifelse } forall
- /File exch (r) file def
- /cfp File fileposition def
- File 4096 string readline
- {
- length 0 eq not { File cfp setfileposition } if
- }
- { exit } ifelse
- {
- File 4096 string readline
- true eq
- {
- dup length 0 eq { pop exit } if
- dup
- CustomHeaders
- { dup 0 get exch 1 get DefMailHeader } forall
- (Subject: ) search
- {
- length 0 eq
- { pop /Title exch def pop () () }
- { pop pop dup } ifelse
- } if
- (Date: ) search
- {
- length 0 eq
- { pop /Date exch def pop () () }
- { pop pop dup } ifelse
- } if
- pop pop
- }
- { pop exit }
- ifelse
- } loop
- File closefile
- } def
-
-
- /PrintMail %% filename
- {
- /File exch def
- mark
- {
- File 4096 string readline
- true eq
- { DoListingLine }
- { pop exit }
- ifelse
- } loop
- File closefile
- cleartomark
- } def
-
-
- /DoListingLine
- {
- ListingFont FindFontISO ListingSize scalefont setfont
- /str exch def
- str stringwidth pop ColumnWidth gt
- {
- /ostr () def
- {
- str ( ) search % remainder ( ) word true
- {
- /word exch ( ) concatstrings def pop
- /remainder exch def
- ostr word concatstrings
- dup stringwidth pop ColumnWidth gt
- {
- pop ostr
- ListingSize /Leading where {pop Leading add} if NewLine
- ListingFont FindFontISO ListingSize scalefont setfont
- XPos YPos moveto show
- /ostr word def
- /str remainder def
- }
- {
- /ostr exch def
- /str remainder def
- } ifelse
- }
- { % string false
- /word exch ( ) concatstrings def
- ostr word concatstrings
- dup stringwidth pop ColumnWidth gt
- {
- pop ostr
- ListingSize /Leading where {pop Leading add} if NewLine
- ListingFont FindFontISO ListingSize scalefont setfont
- XPos YPos moveto show
- /ostr word def
- /str () def
- }
- {
- ListingSize /Leading where {pop Leading add} if NewLine
- ListingFont FindFontISO ListingSize scalefont setfont
- XPos YPos moveto show
- exit
- } ifelse
- } ifelse
- } loop
- }
- {
- ListingSize /Leading where {pop Leading add} if NewLine
- ListingFont FindFontISO ListingSize scalefont setfont
- XPos YPos moveto str show
- }
- ifelse
- } def
-
-
- /NewLine %% Points
- {
- dup
- /XPos BlockLeftEdge def
- /YPos exch neg YPos add def
- YPos BottomMargin lt
- { /YPos TopMargin def
- /BlockLeftEdge BlockRightEdge Gutter add def
- /BlockRightEdge BlockLeftEdge ColumnWidth add def
- /XPos BlockLeftEdge def
- XPos RightMargin 10 sub gt
- {
- EndPage BeginPage
- dup /YPos exch neg YPos add def
- } if
- } if
- pop
- } def
-
-
- /HeadingLeft %% Text
- {
- HeadingSize /Leading where {pop Leading add} if NewLine
- HeadingFont FindFontISO HeadingSize scalefont setfont
- BlockLeftEdge YPos LeftAlign
- } bind def
-
-
- /HorizontalRule
- {
- 0.1 setlinewidth
- ListingSize NewLine
- LeftMargin -10 add YPos moveto
- RightMargin 10 add YPos lineto stroke
- ListingSize NewLine
- } def
-
-
- /PlaceMail %% filename - use this if you want to print mails from
- %% GhostScript's command line.
- {
- /FileName exch def
- FileName (r) file PrintMail
- } def
-
-
- /BeginMail
- {
- /PageNo 1 def BeginPage
- PrintMailHeaders
- BodySize /Leading where {pop Leading add } if NewLine
- /ListingSize BodySize def
- /ListingFont BodyFont def
- } def
-
-
- /EndMail
- {
- EndPage
- } def
-
-
- %% EndProlog
-
-